[][src]Crate filetime

Timestamps for files in Rust

This library provides platform-agnostic inspection of the various timestamps present in the standard fs::Metadata structure.

Installation

Add this to your Cargo.toml:

[dependencies]
filetime = "0.1"

Usage

use std::fs;
use filetime::FileTime;

let metadata = fs::metadata("foo.txt").unwrap();

let mtime = FileTime::from_last_modification_time(&metadata);
println!("{}", mtime);

let atime = FileTime::from_last_access_time(&metadata);
assert!(mtime < atime);

// Inspect values that can be interpreted across platforms
println!("{}", mtime.unix_seconds());
println!("{}", mtime.nanoseconds());

// Print the platform-specific value of seconds
println!("{}", mtime.seconds());

Structs

FileTime

A helper structure to represent a timestamp for a file.

Functions

set_file_times

Set the last access and modification times for a file on the filesystem.

set_symlink_file_times

Set the last access and modification times for a file on the filesystem. This function does not follow symlink.